//====================================================//
//========Eric Muehlberg==============================//
//====================================================//
//========Phoenix Engine==============================//
//====================================================//

#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"
#include "Timer.h"
#include "Camera.h"
#include <string>
#include <sstream>
#include "engine.h"

//Init engine
engine e = engine();

int main(int argc, char* args[])
{
	//Init everything
	if(e.Init() == false)
		return 1;
	e.background = e.load_image("background.png");
	//Timers are used for various Frames per second logic, if you need to use timers for other things
	//you are free to do so, but it might just be easier to use this timer for everything.
	Timer fps = Timer();

	//Start timer
	fps.Start();

	//Game logic loop
	while(e.quit == false)
	{

		//Event Handling loop
		while(SDL_PollEvent(&event))
		{
			if(event.type == SDL_QUIT)
				e.quit = true;

			Uint8 *keystate = SDL_GetKeyState(NULL);

			if(keystate[SDLK_q])
			{
				e.quit = true;
			}
		}

		//Place object update logic here

		//Update timer
		fps.Start();

		//Place display logic here
		
		//Update screen
		if(e.screen != NULL)
			SDL_Flip(e.screen);
	}

	//Call SDL_FreeSurface on every objects sprite member
	//Example: SDL_FreeSurface(mysprite.sprite);

	SDL_FreeSurface(e.background);
	Mix_FreeMusic(e.audio);

	//Close SDL and SDL audio
	Mix_CloseAudio();
	SDL_Quit();

	//End program
	return 0;
}
